PHP Newsletter <?= 9 ?>

Hello everyone, PHP Newsletter is back again, broadcast from Sun* News. This is news about the PHP community recently, check it out!

Hello again, World!

In the previous post we covered PHP 8, and briefly introduced some of the new features of PHP 8. Do you wonder who developed those new functions and what the process for doing so was?  

In this episode, let's learn about the RFC, as well as keep up with the latest news about PHP community activities recently. 

RFC

RFC or Request for Comments is a process first used in computer networks, to refer to detailed documents about new research or changes to network technology, the Internet by an individual or organization. Its purpose is to inform and appeal to the community for comment, evaluation, and criticism, before being approved by the IETF.

Some RFCs you probably already know are:

- rfc7231 - Hypertext Transfer Protocol (HTTP/1.1): Semantics and Content: expressed by HTTP protocol, request methods, request header fields, response status codes, response header fields…

- rfc822 - is often mentioned in the email validate feature of  PHP FILTER_VALIDATE_EMAIL. However, rfc822 is outdated and replaced by rfc2822 and later rfc5322 - Internet Message Format

- rfc3339 - Date and Time on the Internet: Timestamps

And many other RFCs...

With an open-source language like PHP, have you ever wondered who made the changes to the language, who decided to merge pull requests into php-src, and where new features of PHP 7, PHP 8 were from? A process is needed to control these issues, and RFC is applied to PHP as well.

To have a new feature applied in PHP, an individual or group will compose and send RFC on https://wiki.php.net/rfc/ and then notify the community and bring it to the discussion. Finally, there is a vote to see if the RFC is accepted. The voters are from PHP core contributors, including those who contributed much to PHP such as Rasmus Lerdorf (the original author of PHP), Zeev Suraski (Zend Engine developer), Nikita Popov (creator of PHP-Parser and has many contributions to PHP 7),... about 40-50 normal people have participated in the vote.

During discussion or voting, RFC owners will implement and create pull request to strengthen the views presented in RFC. 

The status of a PHP RFC will go from Draft => Under Discussion => Accepted or Declined. After being accepted, the status will switch to Implemented if the feature is merged into PHP core. 

About the specific process to create a PHP RFC, you can read this post

A list of RFCs for PHP 8 here

Many other languages ​​also apply RFC's mindset, for example for JavaScript isTC39 proposals (ECMAScript proposals), Rust RFC, Vue RFC, React RFC,...

Releases

Let's find out about some tools, libraries that have been released or new release versions recently. 

  • Laravel 8: Laravel 8 release with some changes to model and factory, along with the introduction of two new products: Jetstream and Fortify
  • Laravel Jetstream:  Laravel app with built-in functions such as login, registration, email verification, two-factor authentication, session management, API, and team management options. Jetstream is designed and developed using Tailwind CSS, Livewire and InertiaJS. You can consider it as an application base, from which you can develop or customize functions according to individual needs.
  • Laravel Fortify: authentication backend for Laravel including cookie-based authentication, two-factor authentication, and email verification. In an easy way to imagine, Laravel Jetstream is the frontend for login, registration, email verification, two-factor authentication and Laravel Fortify is the backend notes.
  • GitHub CLI 1.0: Github management tool from terminal, released by Github.
  • Vue 3.0 "One Piece": The most remarkable thing in this major release of VueJS is the Composition API with significant performance improvement.
  • Parser Combinators: capable of writing parser (such as custom query syntax, parse smileys code from messages to render emoji, ...) or extract information from text in a way that is easier to read and understand than regex. Some libraries are: Parsica, PHP PPC, PHPLRT
  • Emoji catalog: list of emoji defined in class constants
  • PHP Generator: generate PHP class, function

Remarkable videos

Here are some remarkable videos from the annual PHP events and conferences in 2020

Remarkable posts

  • Some of the common security mistakes in Laravel 
    Most of the time security vulnerabilities are only the result of lack of awareness, not negligence. Sometimes, developers fail to realize how a particular code pattern can lead to vulnerability. In this ebook, CyberPanda Team will share some of the most common security issues, as well as best practices to prevent that they saw during many years of helping startups secure their Laravel applications.  
    Read more: https://blog.laravel.com/unique-rule-sql-injection-warning
  • Enhancements to PHP code coverage in 2020
    With the Xdebug 1.2 and PHPUnit 9.3 release, there have been some improvements in the generate code coverage report. It covers the PHPUnit code coverage and its current limitations. Next are the branch coverage concepts, path coverage, and application in PHPUnit.
  • Modernizing a Legacy PHP Application
    Maintaining old PHP applications is probably something everyone hesitates. But try to see how other people do. The post introduces some anti-patterns that need to be fixed when maintaining old PHP projects.
  • How you shouldn’t use Repository pattern
    How are you applying Repository pattern to an ActiveRecord framework like Laravel? Read our critics on not using the repository pattern in Laravel.
  • Symfony 5: The Fast Track
    A free book written by Symfony founder. The book is about developing a web application from zero to production using Symfony 5, from setting up environment, database, to building interfaces, building admin pages, APIs, building Web SPA applications. ... Even if you've never worked with the Symfony framework, it is worthy to expand your knowledge of the PHP ecosystems, as well as the experience of a senior programmer.
  • How to run over 30k tests in under 5 minutes
    Run over 30k tests in under 5 minutes? Is it possible when the test includes database integration tests? Let's see how they did it.

Other topics:

You may already know

Answer:

1. Is the following code valid, why?

=> See here

The third line in the code in foreach (...) try looks a bit weird but it's completely valid. Actually, it is the same as foreach (...) echo $abc, which is an inline control structure. Although it is valid, normally standard code conventions are not allowed :D Running PHPCS will result in an error: Inline control structures are not allowed. 

2. Does the following code have errors? What will the output be like?

=> See here 

Because the above code uses swith inside foreach, continue works for both switches (for switches, continue works like a break) and foreach. So PHP will throw a warning: Warning: "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? 

This was also noted in PHP Document => https://www.php.net/manual/en/control-structures.continue.php

There will be no questions in this newsletter, but you can test the following code and be careful when using the reference in the loop.

TIPS: PHP support array destructuring, you can use it to make the code more compact without defining temporary variables. 

If you write in regular style:

#PHP